{ "cells": [ { "cell_type": "markdown", "id": "cfde7e57", "metadata": {}, "source": [ "# Event Monitor Tutorial" ] }, { "cell_type": "markdown", "id": "221e3603", "metadata": {}, "source": [ "## Monitor Structure\n", "Description here\n", "\n", "Event Monitor\n", "\n", "* start_monitor\n", "* stop_monitor\n", "* get_monitor_status\n", "* monitor\n", "\n", "Event Sync\n", "\n", "* start_sync\n", "* stop_sync\n", "* watch_sync\n", "* get_sync_status\n", "* sync\n", "\n", "Event Handler\n", "\n", "* start_event_handler\n", "* stop_event_handler\n", "* get_event_handler_status\n", "* event_handler\n", "* handle_event\n", "\n", "Helpers\n", "\n", "* get_events_df\n", "* get_events_list\n", "* get_queue_size\n", "* get_contract_events" ] }, { "cell_type": "markdown", "id": "792338f9", "metadata": {}, "source": [ "## Setup" ] }, { "cell_type": "markdown", "id": "ab357769", "metadata": {}, "source": [ "The event monitor requires a blockexplorer for initialization. The purpose of this blockexplorer is to get the contract source code so that contract interactions (Data & Logs) can be decoded into human readable events. " ] }, { "cell_type": "code", "execution_count": 1, "id": "4e935821", "metadata": {}, "outputs": [], "source": [ "from messari.blockexplorers import Etherscan\n", "\n", "API_KEY = 'YOUR_API_KEY'\n", "ES = Etherscan(api_key=API_KEY)" ] }, { "cell_type": "markdown", "id": "2e7d29c0", "metadata": {}, "source": [ "The event monitor also requires the endpoint for an RPC. This should belong to the same network as the blockexplorer." ] }, { "cell_type": "code", "execution_count": 2, "id": "edf51404", "metadata": {}, "outputs": [], "source": [ "from messari.eventmonitor import EventMonitor\n", "\n", "rpc_url = 'YOUR_RPC_URL'" ] }, { "cell_type": "markdown", "id": "d2dfbc4b", "metadata": {}, "source": [ "Finally the event monitor must be initialized with the adress to monitor for events. " ] }, { "cell_type": "markdown", "id": "8534c5bc", "metadata": {}, "source": [ "NOTE: The source code for this contract must be verified on the selected blockexplorer or else the event monitor will not be able to decode events for the given contract" ] }, { "cell_type": "code", "execution_count": 15, "id": "35e0ad85", "metadata": {}, "outputs": [], "source": [ "DAI = '0x6B175474E89094C44Da98b954EedeAC495271d0F'" ] }, { "cell_type": "markdown", "id": "36e4c2cf", "metadata": {}, "source": [ "Initalize with contract(s), blockexplorer, & RPC" ] }, { "cell_type": "code", "execution_count": 29, "id": "7b8055ed", "metadata": {}, "outputs": [], "source": [ "dai_monitor = EventMonitor(DAI, ES, rpc_url)" ] }, { "cell_type": "markdown", "id": "4bbf2418", "metadata": {}, "source": [ "## Event Monitor" ] }, { "cell_type": "markdown", "id": "1925187d", "metadata": {}, "source": [ "### start_monitor" ] }, { "cell_type": "markdown", "id": "60202b4f", "metadata": {}, "source": [ "Start the event monitor in a dedicated thread. The monitor thread will continue to run until `stop_monitor()` is called. The monitor thread can be accessed with `EventMonitor.monitor_thread`." ] }, { "cell_type": "code", "execution_count": 22, "id": "134c0f16", "metadata": {}, "outputs": [], "source": [ "dai_monitor.start_monitor()" ] }, { "cell_type": "markdown", "id": "fba52d61", "metadata": {}, "source": [ "### stop_monitor" ] }, { "cell_type": "markdown", "id": "62f4507e", "metadata": {}, "source": [ "Stop the event monitor thread. This function will set an internal flag in the `EventMonitor` which tells the monitor thread to exit its loop. The monitor thread will not stop until it finishes the current loop and reaches the top again." ] }, { "cell_type": "code", "execution_count": 9, "id": "49e29f91", "metadata": {}, "outputs": [], "source": [ "dai_monitor.stop_monitor()" ] }, { "cell_type": "markdown", "id": "1d9871ba", "metadata": {}, "source": [ "### get_monitor_status" ] }, { "cell_type": "markdown", "id": "322babce", "metadata": {}, "source": [ "Returns the operating status of the event monitor\n", "- RUNNING: event monitor is running\n", "- STOPPING: event monitor is stopping. If the monitor takes too long to stop then something is likely wrong\n", "- CRASH: event monitor thread crashed.\n", "- DEAD: event monitor is dead/stopped. " ] }, { "cell_type": "code", "execution_count": 23, "id": "12d3a36e", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'RUNNING'" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "monitor_status = dai_monitor.get_monitor_status()\n", "monitor_status" ] }, { "cell_type": "markdown", "id": "a856bd36", "metadata": {}, "source": [ "### monitor" ] }, { "cell_type": "markdown", "id": "2aa0bd23", "metadata": {}, "source": [ "This function runs the main loop for live event monitoring\n", "\n", "WARNING: It is highly recomended that you only interact with this function through the `start_monitor()` and `stop_monitor()` functions, not directly. However if you are inclined, feel free to read the source code for the EventMonitor class and experiment with this function in your own flow/script." ] }, { "cell_type": "code", "execution_count": 7, "id": "b9589716", "metadata": {}, "outputs": [], "source": [ "# dai_monitor.monitor()" ] }, { "cell_type": "markdown", "id": "82163cdd", "metadata": {}, "source": [ "## Event Sync" ] }, { "cell_type": "markdown", "id": "d349df49", "metadata": {}, "source": [ "### start_sync" ] }, { "cell_type": "markdown", "id": "31f75fa6", "metadata": {}, "source": [ "Start the event sync in a dedicated thread. The sync thread will find and submit all events in the given block range to the event handler. The sync thread will continue to run until `stop_sync()` is called or the sync is finished. The sync thread can be accessed with `self.sync_thread`." ] }, { "cell_type": "markdown", "id": "25257893", "metadata": {}, "source": [ "The parameters for this function are:\n", "* start: starting block, default is 0\n", "* end: ending block, default is 'latest'" ] }, { "cell_type": "code", "execution_count": 30, "id": "f53ff554", "metadata": {}, "outputs": [], "source": [ "dai_monitor.start_sync()" ] }, { "cell_type": "markdown", "id": "e569f463", "metadata": {}, "source": [ "### stop_sync" ] }, { "cell_type": "markdown", "id": "60be2ea8", "metadata": {}, "source": [ "Stop the event sync thread. This function will set an internal flag in the `EventMonitor` which tells the sync thread to exit its loop. The sync thread will not stop until it finishes the current loop and reaches the top again." ] }, { "cell_type": "code", "execution_count": 15, "id": "e5718088", "metadata": {}, "outputs": [], "source": [ "dai_monitor.stop_sync()" ] }, { "cell_type": "markdown", "id": "c8ece0f2", "metadata": {}, "source": [ "### watch_sync" ] }, { "cell_type": "markdown", "id": "9fbb6bd3", "metadata": {}, "source": [ "This function can be used to watch the status of any given sync. Every 10 seconds this function will print an update on the progress of a sync.\n", "\n", "NOTE: This is a a blocking function meaning it will be run on the main thread until concluding. ie if there is 10 minutes left in a sync and you call this function, you'll be watching this function for the next 10 minutes" ] }, { "cell_type": "code", "execution_count": 31, "id": "abd12b67", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (5697662 - 10144606), Goal: 13896705, Increment: 4446944\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (7921135 - 9022420), Goal: 13896705, Increment: 1101285\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (7921135 - 8471777), Goal: 13896705, Increment: 550642\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (8471778 - 8976000), Goal: 13896705, Increment: 504222\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (8976001 - 9412808), Goal: 13896705, Increment: 436807\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (9412809 - 9767845), Goal: 13896705, Increment: 355036\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (9767846 - 10029223), Goal: 13896705, Increment: 261377\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (10029224 - 10210828), Goal: 13896705, Increment: 181604\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (10333122 - 10409835), Goal: 13896705, Increment: 76713\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (10454936 - 10480489), Goal: 13896705, Increment: 25553\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (10509427 - 10543235), Goal: 13896705, Increment: 33808\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (10618299 - 10657258), Goal: 13896705, Increment: 38959\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (10728739 - 10757282), Goal: 13896705, Increment: 28543\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (10840419 - 10853032), Goal: 13896705, Increment: 12613\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (10955197 - 11011578), Goal: 13896705, Increment: 56381\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11050341 - 11078194), Goal: 13896705, Increment: 27853\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11112939 - 11123410), Goal: 13896705, Increment: 10471\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11148370 - 11161635), Goal: 13896705, Increment: 13265\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11170081 - 11181350), Goal: 13896705, Increment: 11269\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11209103 - 11221012), Goal: 13896705, Increment: 11909\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11221534 - 11227821), Goal: 13896705, Increment: 6287\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11227822 - 11234248), Goal: 13896705, Increment: 6426\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11252363 - 11258387), Goal: 13896705, Increment: 6024\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11276990 - 11284276), Goal: 13896705, Increment: 7286\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11301454 - 11306157), Goal: 13896705, Increment: 4703\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11317118 - 11323434), Goal: 13896705, Increment: 6316\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11347309 - 11356812), Goal: 13896705, Increment: 9503\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11380420 - 11396898), Goal: 13896705, Increment: 16478\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11438003 - 11443404), Goal: 13896705, Increment: 5401\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11451059 - 11461085), Goal: 13896705, Increment: 10026\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11473170 - 11487031), Goal: 13896705, Increment: 13861\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11538404 - 11559897), Goal: 13896705, Increment: 21493\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11604070 - 11623525), Goal: 13896705, Increment: 19455\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11642682 - 11662231), Goal: 13896705, Increment: 19549\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11704082 - 11725601), Goal: 13896705, Increment: 21519\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11786634 - 11806992), Goal: 13896705, Increment: 20358\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11881481 - 11915394), Goal: 13896705, Increment: 33913\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (11954531 - 11999019), Goal: 13896705, Increment: 44488\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12048340 - 12101150), Goal: 13896705, Increment: 52810\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12155144 - 12206263), Goal: 13896705, Increment: 51119\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12250094 - 12283877), Goal: 13896705, Increment: 33783\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12283878 - 12308600), Goal: 13896705, Increment: 24722\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12325472 - 12337803), Goal: 13896705, Increment: 12331\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12365342 - 12374016), Goal: 13896705, Increment: 8674\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12430868 - 12460147), Goal: 13896705, Increment: 29279\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12460148 - 12499832), Goal: 13896705, Increment: 39684\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12493730 - 12513183), Goal: 13896705, Increment: 19453\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12539967 - 12575137), Goal: 13896705, Increment: 35170\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12622709 - 12652726), Goal: 13896705, Increment: 30017\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12668291 - 12685323), Goal: 13896705, Increment: 17032\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12723853 - 12742160), Goal: 13896705, Increment: 18307\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12759322 - 12776135), Goal: 13896705, Increment: 16813\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12852826 - 12877615), Goal: 13896705, Increment: 24789\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (12937121 - 12972959), Goal: 13896705, Increment: 35838\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (13012798 - 13055415), Goal: 13896705, Increment: 42617\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (13184458 - 13224001), Goal: 13896705, Increment: 39543\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (13260374 - 13295552), Goal: 13896705, Increment: 35178\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (13398430 - 13436224), Goal: 13896705, Increment: 37794\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (13585524 - 13651296), Goal: 13896705, Increment: 65772\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f, Range: (13809698 - 13896483), Goal: 13896705, Increment: 86785\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (7921135 - 10136157), Goal: 13896705, Increment: 2215022\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (7921135 - 9028646), Goal: 13896705, Increment: 1107511\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (9028647 - 9527912), Goal: 13896705, Increment: 499265\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (9527913 - 10381756), Goal: 13896705, Increment: 853843\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (9954835 - 10291120), Goal: 13896705, Increment: 336285\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (10291121 - 10545957), Goal: 13896705, Increment: 254836\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (10545958 - 10722941), Goal: 13896705, Increment: 176983\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (10915298 - 11009681), Goal: 13896705, Increment: 94383\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11091454 - 11103066), Goal: 13896705, Increment: 11612\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11146197 - 11163678), Goal: 13896705, Increment: 17481\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11192180 - 11203058), Goal: 13896705, Increment: 10878\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11192180 - 11203058), Goal: 13896705, Increment: 10878\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11223764 - 11234786), Goal: 13896705, Increment: 11022\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11248889 - 11256555), Goal: 13896705, Increment: 7666\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11277593 - 11289018), Goal: 13896705, Increment: 11425\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11298998 - 11307513), Goal: 13896705, Increment: 8515\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11325773 - 11328397), Goal: 13896705, Increment: 2624\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11341862 - 11351383), Goal: 13896705, Increment: 9521\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11424539 - 11469166), Goal: 13896705, Increment: 44627\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11481110 - 11505047), Goal: 13896705, Increment: 23937\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11561907 - 11591556), Goal: 13896705, Increment: 29649\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11618983 - 11643089), Goal: 13896705, Increment: 24106\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11697032 - 11708298), Goal: 13896705, Increment: 11266\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11747234 - 11759799), Goal: 13896705, Increment: 12565\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11832186 - 11879022), Goal: 13896705, Increment: 46836\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (11911247 - 11957235), Goal: 13896705, Increment: 45988\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12016156 - 12084502), Goal: 13896705, Increment: 68346\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12156362 - 12221206), Goal: 13896705, Increment: 64844\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12270009 - 12300529), Goal: 13896705, Increment: 30520\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12343822 - 12347340), Goal: 13896705, Increment: 3518\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12362904 - 12373535), Goal: 13896705, Increment: 10631\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12456620 - 12470443), Goal: 13896705, Increment: 13823\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12524393 - 12566007), Goal: 13896705, Increment: 41614\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12589728 - 12617754), Goal: 13896705, Increment: 28026\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12681864 - 12699016), Goal: 13896705, Increment: 17152\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12726999 - 12738822), Goal: 13896705, Increment: 11823\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12798988 - 12822097), Goal: 13896705, Increment: 23109\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12849464 - 12883046), Goal: 13896705, Increment: 33582\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (12922762 - 12967495), Goal: 13896705, Increment: 44733\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (13014726 - 13060075), Goal: 13896705, Increment: 45349\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (13192084 - 13216055), Goal: 13896705, Increment: 23971\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (13261273 - 13287233), Goal: 13896705, Increment: 25960\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (13318599 - 13359077), Goal: 13896705, Increment: 40478\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (13411578 - 13480120), Goal: 13896705, Increment: 68542\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (13480121 - 13563468), Goal: 13896705, Increment: 83347\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (13658618 - 13759075), Goal: 13896705, Increment: 100457\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (13759076 - 13854811), Goal: 13896705, Increment: 95735\n", "Contract: 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, Topic: 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929, Range: (13759076 - 13854811), Goal: 13896705, Increment: 95735\n" ] } ], "source": [ "dai_monitor.watch_sync()" ] }, { "cell_type": "markdown", "id": "764296e0", "metadata": {}, "source": [ "### get_sync_status" ] }, { "cell_type": "markdown", "id": "d8170acc", "metadata": {}, "source": [ "Returns the operating status of the event sync\n", "- RUNNING: event sync is running\n", "- STOPPING: event sync is stopping. If the sync takes too long to stop then something is likely wrong\n", "- CRASH: event sync thread crashed.\n", "- DEAD: event sync is dead/stopped. " ] }, { "cell_type": "code", "execution_count": 22, "id": "ecd477e6", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'DEAD'" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sync_status = dai_monitor.get_sync_status()\n", "sync_status" ] }, { "cell_type": "markdown", "id": "37523d34", "metadata": {}, "source": [ "### sync" ] }, { "cell_type": "markdown", "id": "df21ed58", "metadata": {}, "source": [ "This function runs the main loop for syncing" ] }, { "cell_type": "markdown", "id": "d6bb9525", "metadata": {}, "source": [ "WARNING: It is highly recomended that you only interact with this function through the `start_sync()` and `stop_sync()` functions, not directly. However if you are inclined, feel free to read the source code for the EventMonitor class and experiment with this function in your own flow/script." ] }, { "cell_type": "code", "execution_count": null, "id": "334353ba", "metadata": {}, "outputs": [], "source": [ "# dai_monitor.sync(0, 100)" ] }, { "cell_type": "markdown", "id": "5782933d", "metadata": {}, "source": [ "## Event Handler" ] }, { "cell_type": "markdown", "id": "6214b3a1", "metadata": {}, "source": [ "### start_event_handler" ] }, { "cell_type": "markdown", "id": "0317e7b3", "metadata": {}, "source": [ "Start the event handler in a dedicated thread. The handler thread will continue to run until `stop_handler()` is called. The handler thread can be accessed with `self.handler_thread`." ] }, { "cell_type": "markdown", "id": "219fae7e", "metadata": {}, "source": [ "NOTE: this is automatically called with the `start_monitor()` and `start_sync()` functions. You should not have to call this function" ] }, { "cell_type": "code", "execution_count": null, "id": "fe112648", "metadata": {}, "outputs": [], "source": [ "dai_monitor.start_event_handler()" ] }, { "cell_type": "markdown", "id": "6e542239", "metadata": {}, "source": [ "### stop_event_handler" ] }, { "cell_type": "markdown", "id": "3f7930cc", "metadata": {}, "source": [ "Stop the event handler thread. This function will set an internal flag in the `EventMonitor` which tells the handler thread to exit its loop. The sync thread will not stop until it finishes the current loop and reaches the top again." ] }, { "cell_type": "markdown", "id": "9870e829", "metadata": {}, "source": [ "NOTE: The event handler thread will run until all events have been handled, you should be able to let this thread run until completion" ] }, { "cell_type": "code", "execution_count": 21, "id": "d8e547c8", "metadata": {}, "outputs": [], "source": [ "dai_monitor.stop_event_handler()" ] }, { "cell_type": "markdown", "id": "45bd18e9", "metadata": {}, "source": [ "### get_event_handler_status" ] }, { "cell_type": "markdown", "id": "41a73d63", "metadata": {}, "source": [ "Returns the operating status of the event handler" ] }, { "cell_type": "markdown", "id": "e544a548", "metadata": {}, "source": [ "- RUNNING: event handler is running\n", "- STOPPING: event handler is stopping. If the handler takes too long to stop then something is likely wrong\n", "- CRASH: event handler thread crashed.\n", "- DEAD: event handler is dead/stopped. " ] }, { "cell_type": "code", "execution_count": 11, "id": "8607a2ea", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'DEAD'" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "event_handler_status = dai_monitor.get_event_handler_status()\n", "event_handler_status" ] }, { "cell_type": "markdown", "id": "c8dc8b6d", "metadata": {}, "source": [ "### event_handler" ] }, { "cell_type": "markdown", "id": "cc75c1c6", "metadata": {}, "source": [ "This function runs the main loop for event handling" ] }, { "cell_type": "markdown", "id": "b85d4bf7", "metadata": {}, "source": [ "WARNING: It is highly recomended that you only interact with this function through the `start_event_handler()` and `stop_event_handler()` functions, not directly. However if you are inclined, feel free to read the source code for the EventMonitor class and experiment with this function in your own flow/script." ] }, { "cell_type": "code", "execution_count": 23, "id": "c0580e43", "metadata": {}, "outputs": [], "source": [ "# dai_monitor.event_handler()" ] }, { "cell_type": "markdown", "id": "36040fae", "metadata": {}, "source": [ "### handle_event" ] }, { "cell_type": "markdown", "id": "9ec21110", "metadata": {}, "source": [ "WARNING: It is highly recomended that you do not interact with this function. However if you so chose, this function could be overridden to define custom behavior for handling events" ] }, { "cell_type": "markdown", "id": "bba3fa39", "metadata": {}, "source": [ "NOTE: expecting returns from functions called on a w3.eth.filter class" ] }, { "cell_type": "code", "execution_count": 1, "id": "7e1c16d4", "metadata": {}, "outputs": [], "source": [ "# dai_monitor.handle_event(event)" ] }, { "cell_type": "markdown", "id": "5f3e5239", "metadata": {}, "source": [ "## Helpers" ] }, { "cell_type": "markdown", "id": "0cc0cc04", "metadata": {}, "source": [ "### get_events_df" ] }, { "cell_type": "markdown", "id": "3de2338f", "metadata": {}, "source": [ "Returns processed events as a DataFrame" ] }, { "cell_type": "code", "execution_count": 28, "id": "1e579c62", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
argseventtransactionlog_indextransaction_indexaddressblock_numberblock
block_numberlog_index
771083369{'minter': '0x502CB8985B2C92a8d4bf309cDAa89DE9...Mint0xa1b27194b198762eaa631564fea76008b363c157a1cc...691040x4Ddc2D193948926D02f9B1fE9e1daa0718270ED577108330x0ed263de26d3c6dc118d44e8d2b75a8aa9684fbccc13...
771084727{'minter': '0xC8355D0E2C265B2Fe495EbBC0fc9AD99...Mint0x1d2000c49507d94ef42ec995e1ea59b41e61bf0c63d4...27530x4Ddc2D193948926D02f9B1fE9e1daa0718270ED577108470x973c89bdf256cea02cf6eef18fe04e9c4c709939ef38...
771109464{'minter': '0x502CB8985B2C92a8d4bf309cDAa89DE9...Mint0x0eda39d1cb1844e8c2f659219f5a414c0b8261e6dee5...64320x4Ddc2D193948926D02f9B1fE9e1daa0718270ED577110940x8a239157dd06e0514690b8a833f1b2408368f9f049c5...
771179787{'minter': '0x2025A9196d6Fa1011080845c6877f646...Mint0x48ee0eb7b79498b39616c0b8453a15c6dfc04573a08d...871400x4Ddc2D193948926D02f9B1fE9e1daa0718270ED577117970x752b239a445dd274c0971babd6b84944d379a39f3622...
771256379{'minter': '0xBD9ED130A53CFaFcf81502e4D35329A6...Mint0xc440184b091bcc099a18880caecbcb7d5c94228da33e...791180x4Ddc2D193948926D02f9B1fE9e1daa0718270ED577125630x52cc53ce83b7b561a61041322e1c9d3d43d4e9055557...
..............................
824665234{'minter': '0xE82941E727d84F99329b94381E67A945...Mint0x88864e21d8377a179cb90999a332c6fecee3e6051e77...34450x4Ddc2D193948926D02f9B1fE9e1daa0718270ED582466520xf53b11b5ef4b70f57682facdb97f9b9543ec19995648...
824672276{'minter': '0xAB61719309Bf30Cda379B45ac33326B2...Mint0x88c292a8a4169383e0f5cefb0f98fb62e1754eef22fa...76890x4Ddc2D193948926D02f9B1fE9e1daa0718270ED582467220xed71868e646b8a438d237d1b495730e7704b4a426228...
8246729118{'minter': '0xB435871B0959561226b4d903b1abf795...Mint0x2fa76eefb5f261ddb6f2d6c905324f7080cee69194d0...118480x4Ddc2D193948926D02f9B1fE9e1daa0718270ED582467290x68f79c3f252ae2534b9837fdfe78eeae5b3085feaa38...
824679541{'minter': '0x23D6F869C4A64F1E8BE35c777fDc523c...Mint0xfb432a1a866d437a3c0750ae21a05208a19438ebc229...41710x4Ddc2D193948926D02f9B1fE9e1daa0718270ED582467950x34ec0ffc36284a6a32e15a7836ddcf34bd2bd80dd6aa...
824682253{'minter': '0x23D6F869C4A64F1E8BE35c777fDc523c...Mint0x33d4dac9341215e18a9c8fa27c9690ab1430b407d854...53640x4Ddc2D193948926D02f9B1fE9e1daa0718270ED582468220x4944f98a016863441798622dbe3283a162be4362b65b...
\n", "

7569 rows × 8 columns

\n", "
" ], "text/plain": [ " args \\\n", "block_number log_index \n", "7710833 69 {'minter': '0x502CB8985B2C92a8d4bf309cDAa89DE9... \n", "7710847 27 {'minter': '0xC8355D0E2C265B2Fe495EbBC0fc9AD99... \n", "7711094 64 {'minter': '0x502CB8985B2C92a8d4bf309cDAa89DE9... \n", "7711797 87 {'minter': '0x2025A9196d6Fa1011080845c6877f646... \n", "7712563 79 {'minter': '0xBD9ED130A53CFaFcf81502e4D35329A6... \n", "... ... \n", "8246652 34 {'minter': '0xE82941E727d84F99329b94381E67A945... \n", "8246722 76 {'minter': '0xAB61719309Bf30Cda379B45ac33326B2... \n", "8246729 118 {'minter': '0xB435871B0959561226b4d903b1abf795... \n", "8246795 41 {'minter': '0x23D6F869C4A64F1E8BE35c777fDc523c... \n", "8246822 53 {'minter': '0x23D6F869C4A64F1E8BE35c777fDc523c... \n", "\n", " event \\\n", "block_number log_index \n", "7710833 69 Mint \n", "7710847 27 Mint \n", "7711094 64 Mint \n", "7711797 87 Mint \n", "7712563 79 Mint \n", "... ... \n", "8246652 34 Mint \n", "8246722 76 Mint \n", "8246729 118 Mint \n", "8246795 41 Mint \n", "8246822 53 Mint \n", "\n", " transaction \\\n", "block_number log_index \n", "7710833 69 0xa1b27194b198762eaa631564fea76008b363c157a1cc... \n", "7710847 27 0x1d2000c49507d94ef42ec995e1ea59b41e61bf0c63d4... \n", "7711094 64 0x0eda39d1cb1844e8c2f659219f5a414c0b8261e6dee5... \n", "7711797 87 0x48ee0eb7b79498b39616c0b8453a15c6dfc04573a08d... \n", "7712563 79 0xc440184b091bcc099a18880caecbcb7d5c94228da33e... \n", "... ... \n", "8246652 34 0x88864e21d8377a179cb90999a332c6fecee3e6051e77... \n", "8246722 76 0x88c292a8a4169383e0f5cefb0f98fb62e1754eef22fa... \n", "8246729 118 0x2fa76eefb5f261ddb6f2d6c905324f7080cee69194d0... \n", "8246795 41 0xfb432a1a866d437a3c0750ae21a05208a19438ebc229... \n", "8246822 53 0x33d4dac9341215e18a9c8fa27c9690ab1430b407d854... \n", "\n", " log_index transaction_index \\\n", "block_number log_index \n", "7710833 69 69 104 \n", "7710847 27 27 53 \n", "7711094 64 64 32 \n", "7711797 87 87 140 \n", "7712563 79 79 118 \n", "... ... ... \n", "8246652 34 34 45 \n", "8246722 76 76 89 \n", "8246729 118 118 48 \n", "8246795 41 41 71 \n", "8246822 53 53 64 \n", "\n", " address \\\n", "block_number log_index \n", "7710833 69 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5 \n", "7710847 27 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5 \n", "7711094 64 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5 \n", "7711797 87 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5 \n", "7712563 79 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5 \n", "... ... \n", "8246652 34 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5 \n", "8246722 76 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5 \n", "8246729 118 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5 \n", "8246795 41 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5 \n", "8246822 53 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5 \n", "\n", " block_number \\\n", "block_number log_index \n", "7710833 69 7710833 \n", "7710847 27 7710847 \n", "7711094 64 7711094 \n", "7711797 87 7711797 \n", "7712563 79 7712563 \n", "... ... \n", "8246652 34 8246652 \n", "8246722 76 8246722 \n", "8246729 118 8246729 \n", "8246795 41 8246795 \n", "8246822 53 8246822 \n", "\n", " block \n", "block_number log_index \n", "7710833 69 0x0ed263de26d3c6dc118d44e8d2b75a8aa9684fbccc13... \n", "7710847 27 0x973c89bdf256cea02cf6eef18fe04e9c4c709939ef38... \n", "7711094 64 0x8a239157dd06e0514690b8a833f1b2408368f9f049c5... \n", "7711797 87 0x752b239a445dd274c0971babd6b84944d379a39f3622... \n", "7712563 79 0x52cc53ce83b7b561a61041322e1c9d3d43d4e9055557... \n", "... ... \n", "8246652 34 0xf53b11b5ef4b70f57682facdb97f9b9543ec19995648... \n", "8246722 76 0xed71868e646b8a438d237d1b495730e7704b4a426228... \n", "8246729 118 0x68f79c3f252ae2534b9837fdfe78eeae5b3085feaa38... \n", "8246795 41 0x34ec0ffc36284a6a32e15a7836ddcf34bd2bd80dd6aa... \n", "8246822 53 0x4944f98a016863441798622dbe3283a162be4362b65b... \n", "\n", "[7569 rows x 8 columns]" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "events_df = dai_monitor.get_events_df()\n", "events_df" ] }, { "cell_type": "markdown", "id": "9fcfe604", "metadata": {}, "source": [ "### get_events_list" ] }, { "cell_type": "markdown", "id": "71cd44dc", "metadata": {}, "source": [ "Returns process events as a List" ] }, { "cell_type": "code", "execution_count": 12, "id": "1bf70062", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[{'args': {'src': '0xe3eF4F25F436be04Bb45613cC0101b60251996D5',\n", " 'dst': '0x27239549DD40E1D60F5B80B0C4196923745B1FD2',\n", " 'wad': 7536618188544577904079},\n", " 'event': 'Transfer',\n", " 'transaction': '0x0cb8e8ddf2c09e27d57b7a70ec8582958f1463518d6668d4d03ff424690ced6a',\n", " 'log_index': 319,\n", " 'transaction_index': 219,\n", " 'address': '0x6f40d4A6237C257fff2dB00FA0510DeEECd303eb',\n", " 'block_number': 13896436,\n", " 'block': '0xbec26c962fe2fc4b75233b426882b3006ecf1035bf731cca308df333cec26de6'},\n", " {'args': {'src': '0xCba27C8e7115b4Eb50Aa14999BC0866674a96eCB',\n", " 'dst': '0x27239549DD40E1D60F5B80B0C4196923745B1FD2',\n", " 'wad': 5979084303158062514},\n", " 'event': 'Transfer',\n", " 'transaction': '0x0cb8e8ddf2c09e27d57b7a70ec8582958f1463518d6668d4d03ff424690ced6a',\n", " 'log_index': 320,\n", " 'transaction_index': 219,\n", " 'address': '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',\n", " 'block_number': 13896436,\n", " 'block': '0xbec26c962fe2fc4b75233b426882b3006ecf1035bf731cca308df333cec26de6'}]" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "events_list = dai_monitor.get_events_list()\n", "events_list[:2]" ] }, { "cell_type": "markdown", "id": "13958375", "metadata": {}, "source": [ "### get_queue_size" ] }, { "cell_type": "markdown", "id": "2f01ce82", "metadata": {}, "source": [ "Returns the size of the event handler queue. This number represents the amounts of unprocessed events which will be processed so long as `EventMonitor.get_handler_status() == 'RUNNING'`" ] }, { "cell_type": "code", "execution_count": 37, "id": "90f3c244", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1278015" ] }, "execution_count": 37, "metadata": {}, "output_type": "execute_result" } ], "source": [ "event_queue_size = dai_monitor.get_queue_size()\n", "event_queue_size" ] }, { "cell_type": "markdown", "id": "9973c4f7", "metadata": {}, "source": [ "### get_contract_events" ] }, { "cell_type": "markdown", "id": "466dad08", "metadata": {}, "source": [ "This function is used internally for mapping ethereum event topics (HEX) to human readable event names. It can be interesting to see the kinds of events for contracts used to initalize the `EventMonitor` class" ] }, { "cell_type": "code", "execution_count": 17, "id": "e5e4df57", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5
nametextkeccakinputs
0AccrueInterestAccrueInterest(uint256,uint256,uint256)0x875352fb3fadeb8c0be7cbbe8ff761b308fa7033470c...[{'indexed': False, 'name': 'interestAccumulat...
1MintMint(address,uint256,uint256)0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c...[{'indexed': False, 'name': 'minter', 'type': ...
2RedeemRedeem(address,uint256,uint256)0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c...[{'indexed': False, 'name': 'redeemer', 'type'...
3BorrowBorrow(address,uint256,uint256,uint256)0x13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea...[{'indexed': False, 'name': 'borrower', 'type'...
4RepayBorrowRepayBorrow(address,address,uint256,uint256,ui...0x1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dca...[{'indexed': False, 'name': 'payer', 'type': '...
5LiquidateBorrowLiquidateBorrow(address,address,uint256,addres...0x298637f684da70674f26509b10f07ec2fbc77a335ab1...[{'indexed': False, 'name': 'liquidator', 'typ...
6NewPendingAdminNewPendingAdmin(address,address)0xca4f2f25d0898edd99413412fb94012f9e54ec8142f9...[{'indexed': False, 'name': 'oldPendingAdmin',...
7NewAdminNewAdmin(address,address)0xf9ffabca9c8276e99321725bcb43fb076a6c66a54b7f...[{'indexed': False, 'name': 'oldAdmin', 'type'...
8NewComptrollerNewComptroller(address,address)0x7ac369dbd14fa5ea3f473ed67cc9d598964a77501540...[{'indexed': False, 'name': 'oldComptroller', ...
9NewMarketInterestRateModelNewMarketInterestRateModel(address,address)0xedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c419...[{'indexed': False, 'name': 'oldInterestRateMo...
10NewReserveFactorNewReserveFactor(uint256,uint256)0xaaa68312e2ea9d50e16af5068410ab56e1a1fd06037b...[{'indexed': False, 'name': 'oldReserveFactorM...
11ReservesReducedReservesReduced(address,uint256,uint256)0x3bad0c59cf2f06e7314077049f48a93578cd16f5ef92...[{'indexed': False, 'name': 'admin', 'type': '...
12FailureFailure(uint256,uint256,uint256)0x45b96fe442630264581b197e84bbada861235052c5a1...[{'indexed': False, 'name': 'error', 'type': '...
13TransferTransfer(address,address,uint256)0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4...[{'indexed': True, 'name': 'from', 'type': 'ad...
14ApprovalApproval(address,address,uint256)0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2...[{'indexed': True, 'name': 'owner', 'type': 'a...
\n", "
" ], "text/plain": [ " 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5 \\\n", " name \n", "0 AccrueInterest \n", "1 Mint \n", "2 Redeem \n", "3 Borrow \n", "4 RepayBorrow \n", "5 LiquidateBorrow \n", "6 NewPendingAdmin \n", "7 NewAdmin \n", "8 NewComptroller \n", "9 NewMarketInterestRateModel \n", "10 NewReserveFactor \n", "11 ReservesReduced \n", "12 Failure \n", "13 Transfer \n", "14 Approval \n", "\n", " \\\n", " text \n", "0 AccrueInterest(uint256,uint256,uint256) \n", "1 Mint(address,uint256,uint256) \n", "2 Redeem(address,uint256,uint256) \n", "3 Borrow(address,uint256,uint256,uint256) \n", "4 RepayBorrow(address,address,uint256,uint256,ui... \n", "5 LiquidateBorrow(address,address,uint256,addres... \n", "6 NewPendingAdmin(address,address) \n", "7 NewAdmin(address,address) \n", "8 NewComptroller(address,address) \n", "9 NewMarketInterestRateModel(address,address) \n", "10 NewReserveFactor(uint256,uint256) \n", "11 ReservesReduced(address,uint256,uint256) \n", "12 Failure(uint256,uint256,uint256) \n", "13 Transfer(address,address,uint256) \n", "14 Approval(address,address,uint256) \n", "\n", " \\\n", " keccak \n", "0 0x875352fb3fadeb8c0be7cbbe8ff761b308fa7033470c... \n", "1 0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c... \n", "2 0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c... \n", "3 0x13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea... \n", "4 0x1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dca... \n", "5 0x298637f684da70674f26509b10f07ec2fbc77a335ab1... \n", "6 0xca4f2f25d0898edd99413412fb94012f9e54ec8142f9... \n", "7 0xf9ffabca9c8276e99321725bcb43fb076a6c66a54b7f... \n", "8 0x7ac369dbd14fa5ea3f473ed67cc9d598964a77501540... \n", "9 0xedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c419... \n", "10 0xaaa68312e2ea9d50e16af5068410ab56e1a1fd06037b... \n", "11 0x3bad0c59cf2f06e7314077049f48a93578cd16f5ef92... \n", "12 0x45b96fe442630264581b197e84bbada861235052c5a1... \n", "13 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4... \n", "14 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2... \n", "\n", " \n", " inputs \n", "0 [{'indexed': False, 'name': 'interestAccumulat... \n", "1 [{'indexed': False, 'name': 'minter', 'type': ... \n", "2 [{'indexed': False, 'name': 'redeemer', 'type'... \n", "3 [{'indexed': False, 'name': 'borrower', 'type'... \n", "4 [{'indexed': False, 'name': 'payer', 'type': '... \n", "5 [{'indexed': False, 'name': 'liquidator', 'typ... \n", "6 [{'indexed': False, 'name': 'oldPendingAdmin',... \n", "7 [{'indexed': False, 'name': 'oldAdmin', 'type'... \n", "8 [{'indexed': False, 'name': 'oldComptroller', ... \n", "9 [{'indexed': False, 'name': 'oldInterestRateMo... \n", "10 [{'indexed': False, 'name': 'oldReserveFactorM... \n", "11 [{'indexed': False, 'name': 'admin', 'type': '... \n", "12 [{'indexed': False, 'name': 'error', 'type': '... \n", "13 [{'indexed': True, 'name': 'from', 'type': 'ad... \n", "14 [{'indexed': True, 'name': 'owner', 'type': 'a... " ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "contract_events = dai_monitor.get_contract_events()\n", "contract_events" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.9" } }, "nbformat": 4, "nbformat_minor": 5 }